package net.zjitc.servlet.product;

import net.zjitc.service.ProductService;
import net.zjitc.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * 2 * @Author: 洪瑶
 * 3 * @Date: 2018/11/13 11:13
 * 4
 */
@WebServlet(name = "RemoveServlet",urlPatterns = "/removeServlet")
public class RemoveServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        ProductService service = new ProductServiceImpl();
        String pid = request.getParameter("pid");
        int id = Integer.parseInt(pid);
        try {
            service.Delete(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        request.getRequestDispatcher("findPage").forward(request,response);
    }
}
